<tc_include file="Public:head" />
<div class="container" id="container">
	<div class="page">
	    <div class="page__bd" style="height: 100%; overflow: hidden;">
	    	<div class="weui-tab">
	            <div class="weui-tab__panel" style="background: #eeeeee;">
	            	
            	    <div class="weui-cells weui-cells_form" style="margin-bottom: 10px;">
			            <div class="weui-cell">
			                <div class="weui-cell__bd">
			                    <textarea class="weui-textarea" id="textarea" placeholder="请输入反馈意见" rows="6"  oninput="font_siz()"	></textarea>
			                </div>
			            </div>
			            <div class="weui-textarea-counter" style="padding: 0 10px;"><span id="size">0</span>/500</div>
			        </div>
			        <div class="weui-form-preview__ft">
		                <a class="weui-btn weui-btn_orange" href="javascript:sendAdd()" style="padding: 0 50px;">提交</a>
						<p>【客服热线：<a href="tel:021-39887161" style="color:#0d0d0d">021-39887161</a>】</p>
		           </div>
			        
	            </div>
				<tc_include file="Public:menu" />
	    	</div>
	    </div>		    
	</div>
</div>
<div id="dialogs">
	<!--BEGIN regDialog-->
	<div class="js_dialog" id="errDialog" style="display: none;">
		<div class="weui-mask"></div>
		<div class="weui-dialog notice-dialog">
			<div class="weui-dialog__btn">&times;</div>
			<div class="icon-box">
				<i class="icon iconfont icon-notice"></i>
			</div>
			<div class="weui-dialog__bd">
				<div class="weui-dialog__title"></div>
				<p></p>
			</div>
		</div>
	</div>
	<!--END regDialog-->
</div>
<tc_include file="Public:footer" />
<script>
    function show_dialog(title, content) {
        $(".weui-dialog__bd .weui-dialog__title").html(title);
        $(".weui-dialog__bd p").html(content);
        $('#errDialog').fadeIn(0);
    }
    //关闭dialogs
    $('#dialogs').on('click', '.weui-dialog__btn', function(){
        $(this).parents('.js_dialog').fadeOut(0);
    });

    var status = 0;
    function font_siz() {
        var num = $("#textarea").val().length;
        $("#size").text(num);
        if(num>500){
            status = 0;
            $("#size").css('color','red');
        }else{
            $("#size").css('color','#B2B2B2');
            status = 1;
        }

    }
    function sendAdd() {
        var feedBack = $("#textarea").val();
        if (feedBack.length == 0){
            show_dialog('提交失败','反馈内容不能为空');
            return false;
		}
        $("#size").text(status);
        if(status > 0){
            $.post("{:U('feedback/add_post')}", {feedBack:feedBack}, function (data) {
                if (data.code == 200) {
                    show_dialog('提交成功',"");
                    $("#size").text(0)
                    $("#textarea").val('');
                    setTimeout(function(){
                        $('#errDialog').fadeOut(0);
					},1000)
                }else {
                    show_dialog('提交失败', data.message);
                }
            });
        }else{
            show_dialog('提交失败','请检查您的填写字数');
            $("#size").text($("#textarea").val().length);
        }
    }

</script>
</body>
</html>
